package com.wang.mapstruct.convert;

import com.wang.mapstruct.model.UserDTO;
import com.wang.mapstruct.model.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author: wangning
 * @date: 2024/1/2 19:58
 */
@Mapper
public interface UserConvert {

    UserConvert USER_CONVERT =  Mappers.getMapper(UserConvert.class);

    @Mapping(source = "name", target = "username")
    //嵌套映射
    @Mapping(source = "userDTO", target = "userDTO")
    UserVO dto2vo(UserDTO userDTO);

    @Mapping(source = "name", target = "username")
    List<UserVO> dto2vo(List<UserDTO> userList);

}
